
CMAKE_MINIMUM_REQUIRED(VERSION 3.12.1)
PROJECT(openhttps)

option(BUILD_OPENSSL "Build with openssl support" ON)

include_directories(src)
include_directories(test)

set(OPEN_SRC 
	src/wepoll.h 
	src/wepoll.c 
	src/socket_os.h 
	src/socket_os.c 
	src/opensocket.h 
	src/opensocket.cpp
	src/openthread.h
	src/openthread.cpp
	src/openserver.h
	src/openserver.cpp
	src/opentime.h
	src/opentime.cpp
	src/openbuffer.h
	src/openbuffer.cpp
	src/openjson.h
	src/openjson.cpp
	src/openfsm.h
	src/openfsm.cpp
	src/openssl.h
	src/openssl.cpp
	src/openfile.h
	src/openfile.cpp
	src/openstring.h
	src/openstring.cpp
	src/openhttps.h
	src/openhttps.cpp
	src/opencomhttpclient.h
	src/opencomhttpclient.cpp
	src/opencomhttpserver.h
	src/opencomhttpserver.cpp
)

source_group(open FILES ${OPEN_SRC})

add_executable(helloworld 
	${OPEN_SRC}
	test/helloworld.cpp
)

if(BUILD_OPENSSL)

	add_definitions(-DUSE_OPEN_SSL)
	if(CMAKE_SYSTEM_NAME MATCHES "Linux")
	    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -ggdb -Wall -g")
		target_link_libraries(helloworld
			ssl
			crypto
			pthread
		)
	elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
	    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
		#include openssl header
		include_directories(D:/GitHub/openssl-master/include)
		target_link_libraries(helloworld D:/GitHub/openssl-master/libcrypto.lib)
		target_link_libraries(helloworld D:/GitHub/openssl-master/libssl.lib)

	elseif(CMAKE_SYSTEM_NAME MATCHES "Android")

	elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
	else()  
	endif()

else() 

	if(CMAKE_SYSTEM_NAME MATCHES "Linux")
	    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -ggdb -Wall -g")
		target_link_libraries(helloworld
			pthread
		)
	elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
	    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
	elseif(CMAKE_SYSTEM_NAME MATCHES "Android")
	elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -ggdb -Wall -g")
		target_link_libraries(helloworld
			pthread
		)
	else()  
	endif()

endif(BUILD_OPENSSL)


